package com.example.softwareconfigurationcoursedesign.Admin;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
@WebServlet("/deleteUser")
public class DeleteUserServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int userIdToDelete = Integer.parseInt(request.getParameter("userId"));  // 从请求中获取要删除的用户ID

        AdminServletImplement AdminServletImplement = new AdminServlet();  // 创建AdminServletImplement对象
        AdminServletImplement.deleteUserFromDatabase(userIdToDelete);  // 调用AdminServletImplement对象的方法删除数据库中的用户

        System.out.println("删除会员");  // 打印信息到控制台，提示已删除会员
        response.sendRedirect("Admin_User.jsp");  // 重定向到Admin_User.jsp页面
    }
}